<style scoped="">
.lease-info{
	
}
.pic{
	display: inline-block;
	width: 100%;
	max-height: 500upx;
}
.lease-info-box{
	padding: 10upx 30upx;
}
.lease-info-item{
	display: flex;
	flex-direction: row;
	font-size: 32upx;
}
.lease-info-title{
	padding-right:10upx;
	flex-wrap: nowrap;
	white-space: nowrap;
}
.lease-btn{
	margin-top: 20px;
	font-size: 30upx;
}
</style>

<template>
	<view>
		<div class="lease-info">
			<img class="pic" src="http://59.110.234.118:9100/admin/other/1552975303305.jpg" mode=""></img>
			<!-- <image src="http://59.110.234.118:9100/admin/other/1552975303305.jpg" mode=""></image> -->
			<div class="lease-info-box" >
				<div class="lease-info-item">
					<div class="lease-info-title">名称:</div>
					<div class="lease-info-content">{{info.rname}}</div>
				</div>
				<div class="lease-info-item">
					<div class="lease-info-title">介绍:</div>
					<div class="lease-info-content">{{info.content}}</div>
				</div>
				<div class="lease-info-item">
					<div class="lease-info-title">所在店:</div>
					<div class="lease-info-content">{{info.bname}}</div>
				</div>
				<div class="lease-info-item">
					<div class="lease-info-title">地址:</div>
					<div class="lease-info-content">{{info.addr}}</div>
				</div>        
				<!-- <button type="primary" disabled  v-if="info.status==下架">已下架</button> -->
				<button type="primary" disabled  v-if="info.status!='可用'">{{info.status}}</button>
				<button type="primary" disabled  v-if="info.status=='2'">租赁申请中</button>
				<button type="primary" class="lease-btn" v-if="info.status=='可用'">我要租</button>
			</div>
		</div>
	</view>
</template>

<script>
	import {
	    mapState,
	    mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				info:{}
			};
		},
		computed:{
			...mapState(['userInfo'])
		},
		methods:{
			toLease(){
				let that = this
				let uid = this.userInfo.uid
				let bid = this.info.bid
				let did = this.info.did
				if(!uid){
				   uni.navigateTo({
					url:'../../login/login'
				   })
				}else{
					uni.request({
						url: that.httpUrl + 'resLease/lease',
						method: 'POST',
						header: {
							'content-type': 'application/x-www-form-urlencoded'
						},
						data: {
							uid: uid,
							did: did,
							bid:bid
						},
						success: (res) => {
							// console.log(res)
							if (res.data.code == 1) {
								this.info.status = 2
								uni.showToast({
									title: '申请成功，请等待审核',
									icon: 'none',
									mask: true
								})
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none',
									mask: true
								})
							}
						}
					})
				}
			}
		},
		onLoad(options){
			this.info= JSON.parse(options.item)
			console.log(this.info);
		}
	}
</script>
